package com.cskaoyan.javase.oop2._2polymorphic._2advantage;
/**
 * 
 * @since 09:54
 * @author wuguidong@cskaoyan.onaliyun.com
 */
public class Demo3 {
    public static void main(String[] args) {
       Grandfather gf =  new Grandson();
       // gf这个引用可以强转成哪些引用?
        Grandson gs = (Grandson) gf;
        Son s = (Son) gf;
        Father f = (Father) gf;

        // 错误的强转,会导致程序抛出ClassCastException异常,程序终止
        Father2 f2 = (Father2) gf;
    }
}
class Grandfather{}
class Father2 extends Grandfather{}
class Father extends Grandfather{}
class Son extends Father{}
class Grandson extends Son{}